﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using LGSVR.Common;
using System.Data;

namespace LGSVR.BLL.Program
{
    public class MessageInfo
    {
        //public string GetstrValue(string strTableName, string strField,string strWhere)
        //{
        //    string sql = "select count(*) from cardType where state=1 and [TypeID]=@TypeID";
           
        //    List<SqlParameter> lstParam = new List<SqlParameter>();
        //    lstParam.Add(new SqlParameter("@TypeID", typeID));
        //    lstParam.Add(new SqlParameter("@ID", id));

        //    int len = Convert.ToInt32(SQLHelper.GetScale(sql, System.Data.CommandType.Text, lstParam.ToArray()));
        //    return len > 0;
        //}

        public string GetstrValue(string sql)
        {
            //string sql = "select * from cardType where state=1 ";

            List<SqlParameter> lstParam = new List<SqlParameter>();
            DataTable dt = SQLHelper.GetDataTable(sql, CommandType.Text, lstParam.ToArray());
            if (dt != null && dt.Rows.Count > 0)
                return dt.Rows[0][0].ToString();
            return string.Empty;
        }

        public int GetintValue(string sql)
        {
            //string sql = "select * from cardType where state=1 ";
            //sql += " Where 0<>@ID";
            List<SqlParameter> lstParam = new List<SqlParameter>();
            lstParam.Add(new SqlParameter("@ID", "1"));
            //DataTable dt = SQLHelper.GetDataTable(sql, CommandType.Text, lstParam.ToArray());
            object o = SQLHelper.GetScale(sql, System.Data.CommandType.Text, lstParam.ToArray());

            try
            {
                return Convert.ToInt32(o);
            }
            catch
            {
            return 0;
            }
        }

        public int GetintValue(string sql, string strparameters,string strValue)
        {
            //string sql = "select * from cardType where state=1 ";
            //sql += " Where 0<>@ID";
            List<SqlParameter> lstParam = new List<SqlParameter>();
            lstParam.Add(new SqlParameter(strparameters, strValue));
            //DataTable dt = SQLHelper.GetDataTable(sql, CommandType.Text, lstParam.ToArray());
            object o = SQLHelper.GetScale(sql, System.Data.CommandType.Text, lstParam.ToArray());

            try
            {
                return Convert.ToInt32(o);
            }
            catch
            {
                return 0;
            }
        }


       


    }
}
